/**
 * Selling Partner API for Orders
 * Use the Orders Selling Partner API to programmatically retrieve order information. With this API, you can develop fast, flexible, and custom applications to manage order synchronization, perform order research, and create demand-based decision support tools.   _Note:_ For the JP, AU, and SG marketplaces, the Orders API supports orders from 2016 onward. For all other marketplaces, the Orders API supports orders for the last two years (orders older than this don't show up in the response).
 *
 * The version of the OpenAPI document: v0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 *
 */

import { ApiClient } from '../ApiClient.js'
import { AmazonPrograms } from './AmazonPrograms.js'
import { AssociatedItem } from './AssociatedItem.js'
import { BuyerRequestedCancel } from './BuyerRequestedCancel.js'
import { ItemBuyerInfo } from './ItemBuyerInfo.js'
import { Measurement } from './Measurement.js'
import { Money } from './Money.js'
import { PointsGrantedDetail } from './PointsGrantedDetail.js'
import { ProductInfoDetail } from './ProductInfoDetail.js'
import { ShippingConstraints } from './ShippingConstraints.js'
import { SubstitutionPreferences } from './SubstitutionPreferences.js'
import { TaxCollection } from './TaxCollection.js'

/**
 * The OrderItem model module.
 * @module orders_v0/model/OrderItem
 * @version v0
 */
export class OrderItem {
  /**
   * Constructs a new <code>OrderItem</code>.
   * A single order item.
   * @alias module:orders_v0/model/OrderItem
   * @class
   * @param ASIN {String} The item's Amazon Standard Identification Number (ASIN).
   * @param orderItemId {String} An Amazon-defined order item identifier.
   * @param quantityOrdered {Number} The number of items in the order.
   */
  constructor (ASIN, orderItemId, quantityOrdered) {
    this.ASIN = ASIN
    this.orderItemId = orderItemId
    this.quantityOrdered = quantityOrdered
  }

  /**
   * Constructs a <code>OrderItem</code> from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {OrderItem} obj Optional instance to populate.
   * @return {OrderItem} The populated <code>OrderItem</code> instance.
   */
  static constructFromObject (data, obj) {
    if (data) {
      switch (typeof data) {
        case 'string':
          obj = String(data)
          break
        case 'number':
          obj = Number(data)
          break
        case 'boolean':
          obj = Boolean(data)
          break
      }
      obj = obj || new OrderItem()
      if (data.hasOwnProperty('ASIN')) { obj.ASIN = ApiClient.convertToType(data.ASIN, 'String') }
      if (data.hasOwnProperty('SellerSKU')) { obj.sellerSKU = ApiClient.convertToType(data.SellerSKU, 'String') }
      if (data.hasOwnProperty('OrderItemId')) { obj.orderItemId = ApiClient.convertToType(data.OrderItemId, 'String') }
      if (data.hasOwnProperty('AssociatedItems')) { obj.associatedItems = ApiClient.convertToType(data.AssociatedItems, [AssociatedItem]) }
      if (data.hasOwnProperty('Title')) { obj.title = ApiClient.convertToType(data.Title, 'String') }
      if (data.hasOwnProperty('QuantityOrdered')) { obj.quantityOrdered = ApiClient.convertToType(data.QuantityOrdered, 'Number') }
      if (data.hasOwnProperty('QuantityShipped')) { obj.quantityShipped = ApiClient.convertToType(data.QuantityShipped, 'Number') }
      if (data.hasOwnProperty('ProductInfo')) { obj.productInfo = ProductInfoDetail.constructFromObject(data.ProductInfo) }
      if (data.hasOwnProperty('PointsGranted')) { obj.pointsGranted = PointsGrantedDetail.constructFromObject(data.PointsGranted) }
      if (data.hasOwnProperty('ItemPrice')) { obj.itemPrice = Money.constructFromObject(data.ItemPrice) }
      if (data.hasOwnProperty('ShippingPrice')) { obj.shippingPrice = Money.constructFromObject(data.ShippingPrice) }
      if (data.hasOwnProperty('ItemTax')) { obj.itemTax = Money.constructFromObject(data.ItemTax) }
      if (data.hasOwnProperty('ShippingTax')) { obj.shippingTax = Money.constructFromObject(data.ShippingTax) }
      if (data.hasOwnProperty('ShippingDiscount')) { obj.shippingDiscount = Money.constructFromObject(data.ShippingDiscount) }
      if (data.hasOwnProperty('ShippingDiscountTax')) { obj.shippingDiscountTax = Money.constructFromObject(data.ShippingDiscountTax) }
      if (data.hasOwnProperty('PromotionDiscount')) { obj.promotionDiscount = Money.constructFromObject(data.PromotionDiscount) }
      if (data.hasOwnProperty('PromotionDiscountTax')) { obj.promotionDiscountTax = Money.constructFromObject(data.PromotionDiscountTax) }
      if (data.hasOwnProperty('PromotionIds')) { obj.promotionIds = ApiClient.convertToType(data.PromotionIds, ['String']) }
      if (data.hasOwnProperty('CODFee')) { obj.cODFee = Money.constructFromObject(data.CODFee) }
      if (data.hasOwnProperty('CODFeeDiscount')) { obj.cODFeeDiscount = Money.constructFromObject(data.CODFeeDiscount) }
      if (data.hasOwnProperty('IsGift')) { obj.isGift = ApiClient.convertToType(data.IsGift, 'String') }
      if (data.hasOwnProperty('ConditionNote')) { obj.conditionNote = ApiClient.convertToType(data.ConditionNote, 'String') }
      if (data.hasOwnProperty('ConditionId')) { obj.conditionId = ApiClient.convertToType(data.ConditionId, 'String') }
      if (data.hasOwnProperty('ConditionSubtypeId')) { obj.conditionSubtypeId = ApiClient.convertToType(data.ConditionSubtypeId, 'String') }
      if (data.hasOwnProperty('ScheduledDeliveryStartDate')) { obj.scheduledDeliveryStartDate = ApiClient.convertToType(data.ScheduledDeliveryStartDate, 'String') }
      if (data.hasOwnProperty('ScheduledDeliveryEndDate')) { obj.scheduledDeliveryEndDate = ApiClient.convertToType(data.ScheduledDeliveryEndDate, 'String') }
      if (data.hasOwnProperty('PriceDesignation')) { obj.priceDesignation = ApiClient.convertToType(data.PriceDesignation, 'String') }
      if (data.hasOwnProperty('TaxCollection')) { obj.taxCollection = TaxCollection.constructFromObject(data.TaxCollection) }
      if (data.hasOwnProperty('SerialNumberRequired')) { obj.serialNumberRequired = ApiClient.convertToType(data.SerialNumberRequired, 'Boolean') }
      if (data.hasOwnProperty('IsTransparency')) { obj.isTransparency = ApiClient.convertToType(data.IsTransparency, 'Boolean') }
      if (data.hasOwnProperty('IossNumber')) { obj.iossNumber = ApiClient.convertToType(data.IossNumber, 'String') }
      if (data.hasOwnProperty('StoreChainStoreId')) { obj.storeChainStoreId = ApiClient.convertToType(data.StoreChainStoreId, 'String') }
      if (data.hasOwnProperty('DeemedResellerCategory')) { obj.deemedResellerCategory = ApiClient.convertToType(data.DeemedResellerCategory, 'String') }
      if (data.hasOwnProperty('BuyerInfo')) { obj.buyerInfo = ItemBuyerInfo.constructFromObject(data.BuyerInfo) }
      if (data.hasOwnProperty('BuyerRequestedCancel')) { obj.buyerRequestedCancel = BuyerRequestedCancel.constructFromObject(data.BuyerRequestedCancel) }
      if (data.hasOwnProperty('SerialNumbers')) { obj.serialNumbers = ApiClient.convertToType(data.SerialNumbers, ['String']) }
      if (data.hasOwnProperty('SubstitutionPreferences')) { obj.substitutionPreferences = SubstitutionPreferences.constructFromObject(data.SubstitutionPreferences) }
      if (data.hasOwnProperty('Measurement')) { obj.measurement = Measurement.constructFromObject(data.Measurement) }
      if (data.hasOwnProperty('ShippingConstraints')) { obj.shippingConstraints = ShippingConstraints.constructFromObject(data.ShippingConstraints) }
      if (data.hasOwnProperty('AmazonPrograms')) { obj.amazonPrograms = AmazonPrograms.constructFromObject(data.AmazonPrograms) }
    }
    return obj
  }
}

/**
 * The item's Amazon Standard Identification Number (ASIN).
 * @member {String} ASIN
 * @type {String}
 */
OrderItem.prototype.ASIN = undefined

/**
 * The item's seller stock keeping unit (SKU).
 * @member {String} sellerSKU
 * @type {String}
 */
OrderItem.prototype.sellerSKU = undefined

/**
 * An Amazon-defined order item identifier.
 * @member {String} orderItemId
 * @type {String}
 */
OrderItem.prototype.orderItemId = undefined

/**
 * A list of associated items that a customer has purchased with a product. For example, a tire installation service purchased with tires.
 * @member {[AssociatedItem]} associatedItems
 * @type {[AssociatedItem]}
 */
OrderItem.prototype.associatedItems = undefined

/**
 * The item's name.
 * @member {String} title
 * @type {String}
 */
OrderItem.prototype.title = undefined

/**
 * The number of items in the order.
 * @member {Number} quantityOrdered
 * @type {Number}
 */
OrderItem.prototype.quantityOrdered = undefined

/**
 * The number of items shipped.
 * @member {Number} quantityShipped
 * @type {Number}
 */
OrderItem.prototype.quantityShipped = undefined

/**
 * @member {ProductInfoDetail} productInfo
 * @type {ProductInfoDetail}
 */
OrderItem.prototype.productInfo = undefined

/**
 * @member {PointsGrantedDetail} pointsGranted
 * @type {PointsGrantedDetail}
 */
OrderItem.prototype.pointsGranted = undefined

/**
 * @member {Money} itemPrice
 * @type {Money}
 */
OrderItem.prototype.itemPrice = undefined

/**
 * @member {Money} shippingPrice
 * @type {Money}
 */
OrderItem.prototype.shippingPrice = undefined

/**
 * @member {Money} itemTax
 * @type {Money}
 */
OrderItem.prototype.itemTax = undefined

/**
 * @member {Money} shippingTax
 * @type {Money}
 */
OrderItem.prototype.shippingTax = undefined

/**
 * @member {Money} shippingDiscount
 * @type {Money}
 */
OrderItem.prototype.shippingDiscount = undefined

/**
 * @member {Money} shippingDiscountTax
 * @type {Money}
 */
OrderItem.prototype.shippingDiscountTax = undefined

/**
 * @member {Money} promotionDiscount
 * @type {Money}
 */
OrderItem.prototype.promotionDiscount = undefined

/**
 * @member {Money} promotionDiscountTax
 * @type {Money}
 */
OrderItem.prototype.promotionDiscountTax = undefined

/**
 * A list of promotion identifiers provided by the seller when the promotions were created.
 * @member {[String]} promotionIds
 * @type {[String]}
 */
OrderItem.prototype.promotionIds = undefined

/**
 * @member {Money} cODFee
 * @type {Money}
 */
OrderItem.prototype.cODFee = undefined

/**
 * @member {Money} cODFeeDiscount
 * @type {Money}
 */
OrderItem.prototype.cODFeeDiscount = undefined

/**
 * Indicates whether the item is a gift.  **Possible values**: `true` and `false`.
 * @member {String} isGift
 * @type {String}
 */
OrderItem.prototype.isGift = undefined

/**
 * The condition of the item, as described by the seller.
 * @member {String} conditionNote
 * @type {String}
 */
OrderItem.prototype.conditionNote = undefined

/**
 * The condition of the item.  **Possible values**: `New`, `Used`, `Collectible`, `Refurbished`, `Preorder`, and `Club`.
 * @member {String} conditionId
 * @type {String}
 */
OrderItem.prototype.conditionId = undefined

/**
 * The subcondition of the item.  **Possible values**: `New`, `Mint`, `Very Good`, `Good`, `Acceptable`, `Poor`, `Club`, `OEM`, `Warranty`, `Refurbished Warranty`, `Refurbished`, `Open Box`, `Any`, and `Other`.
 * @member {String} conditionSubtypeId
 * @type {String}
 */
OrderItem.prototype.conditionSubtypeId = undefined

/**
 * The start date of the scheduled delivery window in the time zone for the order destination. In [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format.
 * @member {String} scheduledDeliveryStartDate
 * @type {String}
 */
OrderItem.prototype.scheduledDeliveryStartDate = undefined

/**
 * The end date of the scheduled delivery window in the time zone for the order destination. In [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format.
 * @member {String} scheduledDeliveryEndDate
 * @type {String}
 */
OrderItem.prototype.scheduledDeliveryEndDate = undefined

/**
 * Indicates that the selling price is a special price that is only available for Amazon Business orders. For more information about the Amazon Business Seller Program, refer to the [Amazon Business website](https://www.amazon.com/b2b/info/amazon-business).   **Possible values**: `BusinessPrice`
 * @member {String} priceDesignation
 * @type {String}
 */
OrderItem.prototype.priceDesignation = undefined

/**
 * @member {TaxCollection} taxCollection
 * @type {TaxCollection}
 */
OrderItem.prototype.taxCollection = undefined

/**
 * When true, the product type for this item has a serial number.   Only returned for Amazon Easy Ship orders.
 * @member {Boolean} serialNumberRequired
 * @type {Boolean}
 */
OrderItem.prototype.serialNumberRequired = undefined

/**
 * When true, the ASIN is enrolled in Transparency. The Transparency serial number that you must submit is determined by:  **1D or 2D Barcode:** This has a **T** logo. Submit either the 29-character alpha-numeric identifier beginning with **AZ** or **ZA**, or the 38-character Serialized Global Trade Item Number (SGTIN). **2D Barcode SN:** Submit the 7- to 20-character serial number barcode, which likely has the prefix **SN**. The serial number is applied to the same side of the packaging as the GTIN (UPC/EAN/ISBN) barcode. **QR code SN:** Submit the URL that the QR code generates.
 * @member {Boolean} isTransparency
 * @type {Boolean}
 */
OrderItem.prototype.isTransparency = undefined

/**
 * The IOSS number of the marketplace. Sellers shipping to the EU from outside the EU must provide this IOSS number to their carrier when Amazon has collected the VAT on the sale.
 * @member {String} iossNumber
 * @type {String}
 */
OrderItem.prototype.iossNumber = undefined

/**
 * The store chain store identifier. Linked to a specific store in a store chain.
 * @member {String} storeChainStoreId
 * @type {String}
 */
OrderItem.prototype.storeChainStoreId = undefined

/**
 * Allowed values for the <code>DeemedResellerCategory</code> property.
 * @enum {String}
 * @readonly
 */
OrderItem.DeemedResellerCategoryEnum = {

  /**
     * value: "IOSS"
     * @const
     */
  IOSS: 'IOSS',

  /**
     * value: "UOSS"
     * @const
     */
  UOSS: 'UOSS'
}

/**
 * The category of deemed reseller. This applies to selling partners that are not based in the EU and is used to help them meet the VAT Deemed Reseller tax laws in the EU and UK.
 * @member {String} deemedResellerCategory
 * @type {String}
 */
OrderItem.prototype.deemedResellerCategory = undefined

/**
 * @member {ItemBuyerInfo} buyerInfo
 * @type {ItemBuyerInfo}
 */
OrderItem.prototype.buyerInfo = undefined

/**
 * @member {BuyerRequestedCancel} buyerRequestedCancel
 * @type {BuyerRequestedCancel}
 */
OrderItem.prototype.buyerRequestedCancel = undefined

/**
 * A list of serial numbers for electronic products that are shipped to customers. Returned for FBA orders only.
 * @member {[String]} serialNumbers
 * @type {[String]}
 */
OrderItem.prototype.serialNumbers = undefined

/**
 * @member {SubstitutionPreferences} substitutionPreferences
 * @type {SubstitutionPreferences}
 */
OrderItem.prototype.substitutionPreferences = undefined

/**
 * @member {Measurement} measurement
 * @type {Measurement}
 */
OrderItem.prototype.measurement = undefined

/**
 * @member {ShippingConstraints} shippingConstraints
 * @type {ShippingConstraints}
 */
OrderItem.prototype.shippingConstraints = undefined

/**
 * @member {AmazonPrograms} amazonPrograms
 * @type {AmazonPrograms}
 */
OrderItem.prototype.amazonPrograms = undefined
